#include<iostream>
#include<bitset>
#include<vector>
using namespace std;
bitset<200010> bs;
bitset<200010> del;
int main(){
    freopen("fruit.in","r",stdin);
    freopen("fruit.out","w",stdout);
    int n,x;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x;
        bs[i] = static_cast<bool>(x);
        del[i] = false;
    }
    bool lastone,is1;
    vector<int> basket;
    int rem=n;
    while(rem){
        is1 = true;
        basket.clear();
        for(int i=0;i<n;i++){
            if(del[i])continue;
            if((lastone!=bs[i])||is1){
                del[i] = true;
                is1=false;
                lastone = bs[i];
                basket.push_back(i);
            }
        }
        rem -= basket.size();
        for(int i=0;i<basket.size();i++){
            cout << basket[i]+1 << " ";
        }
        cout << endl;
    }
    return 0;
}
/*
12
1 1 0 0 1 1 1 0 1 1 0 0
*/
